﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;

namespace YArchitech.Plumbing
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class LayTheFloorDrain : HYNoTranExternalCommand
	{
		public override Result HYExecute()
		{
			this.tran = new Transaction(base.Doc, "布置地漏");
			this.tran.Start();
			FamilySymbol settedFamilySymbol = HYDrainageSystemSetting.Instance.GetSettedFamilySymbol(base.Doc, HYFamilySymbolSign.FloorDrain);
			this.tran.Commit();
			base.UiDoc.PromptForFamilyInstancePlacement(settedFamilySymbol);
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public override void TailProcess()
		{
			if (this.tran != null && (int)this.tran.GetStatus() != 3)
			{
				this.tran.RollBack();
			}
		}

		private Transaction tran;
	}
}
